<template>
    <div class="complaint">
        <el-row>
            <el-col :span="24" class="base-mian-cell" v-if="cusFlag">
                <div class="base-mian-cell-title clearfix">
                    <div class="left fl">
                        <span class="line">|</span>
                        <span class="tips">{{title}}</span>
                    </div>
                    <div class="right fr" @click="changeView">
                        <i class="el-icon-circle-close"></i>
                    </div>
                </div>
                <div class="base-mian-cell-main">
                    <el-table
                            :data="cusData"
                            style="width: 100%">
                        <el-table-column width="35" property="cltind" label=" ">
                          <template slot-scope="scope">
                              <span v-if="scope.row.cltind=='C'">+</span>
                              <span v-else-if="scope.row.cltind=='D'">D</span>
                              <span v-else>{{scope.row.cltind}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column
                                prop="clntnum"
                                label="客户号码"
                                min-width="120"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="secuityno"
                                label="证件号码"
                                min-width="200"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="surname"
                                label="客户姓名"
                                min-width="160"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="cltsex"
                                label="性别"
                                min-width="60"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="cltdob"
                                label="出生日期"
                                min-width="120"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="ctrycode"
                                label="国籍/地区"
                                min-width="120"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="cltphone01"
                                label="电话(H)"
                                min-width="120"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="cltphone02"
                                label="电话(O)"
                                min-width="200"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="marryd"
                                label="婚姻状况"
                                min-width="100"
                                show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column
                                prop="faxno"
                                label="传真机号码"
                                min-width="120"
                                show-overflow-tooltip>
                        </el-table-column>
<!--                        <el-table-column
                                prop="cltaddr01"
                                label="地址"
                                min-width="300"
                                show-overflow-tooltip>
                        </el-table-column>-->

                        <el-table-column
                          prop="cltaddr"
                          label="地址"
                          min-width="300"
                          show-overflow-tooltip>
                        </el-table-column>

                    </el-table>
                </div>
            </el-col>
        </el-row>


    </div>
</template>
<script>
  import constant from '@/utils/constant';
  import uwLoadJs from '@/utils/uwLoad';
  import appName from '@/api/appName';

  export default {
    data() {
      return {
        cusData: [],
        title:"客户查询",
        opinionDialogVisible2: false,
        historys: [],
        detail: {},
          initDataTimeOut:null,
      }
    },
    props: {
      cusFlag: {
        type: Boolean,
        default: false
      },
      reqtype: {
        type: String,
        default: ""
      },
      applnum: {
        type: String,
        default: ""
      }
    },
      destroyed() {
        clearTimeout(this.initDataTimeOut)
      },
      methods: {
      changeView() {
        this.$emit('subCusFlag', false);
      },
      //将值转换成日期形式
      castDate(val) {
        let newVal = null;
        if (val == "0") {
          newVal = "0000/00/00"
        } else {
          if (val.length == 8) {
            newVal = val.substring(0, 4) + "/" + val.substring(4, 6) + "/" + val.substring(6, 8);
          }
        }
        return newVal;
      },
      castAddr(addr01,addr02,addr03,addr04,addr05) {
        let addrStr = "";
        addrStr = addr01 + addr02 + addr03 + addr04 + addr05;
        if (addrStr.length == 0) {
          return addr01;
        }
        return addrStr.trim();
      },
      initData() {
        let that = this;
        let roleflag = "";
        if (this.reqtype == "ins") {
          roleflag = "2"
          this.title = "被保人客户查询";
        } else if (this.reqtype == "ins2") {
          roleflag = "4";
          this.title = "第二被保人客户查询";
        }else {
          roleflag = "1";
          this.title = "投保人客户查询";
        }
        let params = {
          "roleflag": roleflag,
          "applnum": that.applnum
        }
        that.$emit('showLoading', true);
        this.initDataTimeOut = setTimeout(function () {
          that.cusData = [];
          let url = appName.NEWUNDR + '/unipnd/customer/findPolicyByApplnum';
          let res = uwLoadJs.ajaxRequest(params, url);
          that.$emit('showLoading', false);
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            res.data.forEach(item=>{
              item['cltdob'] = that.castDate(item.as_cltdob);
              item['cltaddr'] = that.castAddr(item.cltaddr01, item.cltaddr02, item.cltaddr03, item.cltaddr04, item.cltaddr05);
              that.cusData.push(item);
            })
          }

        }, 100)

      },


    },
    created() {
      this.initData();
    },
    filters: {}
  }
</script>
<style lang="less" scoped>

</style>
